#ifndef JZLOG_MANAGER_H_
#define JZLOG_MANAGER_H_

#include <QObject>
#include <QString>
#include <QMutex>
#include <QFile>
#include <QTimer>
#include <QDate>
#include <QMap>
#include <QSharedPointer>

enum {
    LOG_DEBUG,
    LOG_INFO,
    LOG_WARNING,
    LOG_ERROR,
    LOG_FATAL,
};

class JZLogObject
{
public:
    int level;
    int64_t time;        
    QString message;    
};
typedef QSharedPointer<JZLogObject> JZLogObjectPtr;

class JZLogManager : public QObject
{
    Q_OBJECT

public:
    static JZLogManager *instance();

    void init();
    void log(int module, int level, const QString &format, ...);        

signals:
    void sigLog(JZLogObjectPtr log);

protected slots:
    void onTimeOut();

protected:
    JZLogManager();
    ~JZLogManager();

    QTimer *m_timer;
};

#define LOGD(format,...)  JZLogManager::instance()->log(LOG_DEBUG,format,##__VA_ARGS__)
#define LOGI(format,...)  JZLogManager::instance()->log(LOG_INFO,format,##__VA_ARGS__)
#define LOGW(format,...)  JZLogManager::instance()->log(LOG_WARNING,format,##__VA_ARGS__)
#define LOGE(format,...)  JZLogManager::instance()->log(LOG_ERROR,format,##__VA_ARGS__)
#define LOGF(format,...)  JZLogManager::instance()->log(LOG_FATAL,format,##__VA_ARGS__)


#endif